/*!
 * \file frmem_chk.h
 *
 * \brief 内存检查
 *
 * All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.\n
 * 内存检查
 *
 * \version 2.0
 * \author yaohl
 * \date 2014/10/10
 *
 */


#ifndef __FRMEM_CHK_H_
#define __FRMEM_CHK_H_

#include "frmem_cfg.h"

/* 内存检查 */
#if FR_MEM_LEAK_CHECK
    int  __fr_memchk_init(const char *p_name, const char *p_fname, const char *p_fun, int i_lineno);
    //void* __fr_memchk_init2(const char *p_name, const char *p_fname, const char *p_fun, int i_lineno);
    void __fr_memchk_stat(char **pp_outbuff);
    void __fr_memchk_destroy(const char *p_fname, const char *p_fun, int i_lineno);

    #define __frcomm_slab_init(x, y)  __fr_memchk_init(y, __FILE__, __FUNCTION__, __LINE__)
    //#define __frcomm_slab_init2(x, y)  __fr_memchk_init2(y, __FILE__, __FUNCTION__, __LINE__)
    #define __frcomm_slab_stat(x)     __fr_memchk_stat(x)
    #define __frcomm_slab_destroy()   __fr_memchk_destroy(__FILE__, __FUNCTION__, __LINE__)

    void *__fr_memchk_malloc(size_t , const char *, const char *, int );
    char *__fr_memchk_strdup(const char *, const char *, const char *, int);
    void  __fr_memchk_free(void *, const char *, const char *, int );
    void *__fr_memchk_memdup(const void *, size_t , const char *, const char *, int );

    #define __frcomm_malloc(x)         __fr_memchk_malloc(x, __FILE__, __FUNCTION__, __LINE__)
    //#define __frcomm_malloc2(x,y)      __fr_memchk_malloc(x, __FILE__, __FUNCTION__, __LINE__)
    #define __frcomm_strdup(x)         __fr_memchk_strdup(x, __FILE__, __FUNCTION__, __LINE__)
    #define __frcomm_memdup(x,y)       __fr_memchk_memdup(x, y, __FILE__, __FUNCTION__, __LINE__)
    #define __frcomm_free(x)           __fr_memchk_free(x, __FILE__, __FUNCTION__, __LINE__)
#endif

#endif

